import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
import store from '../store'
const routes = [
  {
    path: '/',
    component: () => import('@/page/index/index.vue'),
  },
  {
    path: '/category',
    component: () => import('@/page/index/category/index.vue')
  },
  {
    path: '/proguct/:id',
    component: () => import('@/page/index/progouct/index.vue'),
  },
  {
    path: '/login',
    component: () => import('@/page/login/index.vue')
  },
  {
    path:'/cart',
    component:()=> import('@/page/index/Cart.vue')
  },
  {
    path:'/demo',
    component:()=>import('@/views/Layout.vue')
  },
  {
    path:'/city',
    component:()=>import('@/views/index.vue')
  }
]

const router = new VueRouter({
  routes
})
 router.beforeEach((to,from,next)=>{
  console.log(store);
  if(to.path=='/cart'){
    // if()
    next('/login');
  }else{
    next()
  }
 })
export default router
